package com.datou.service.impl;

import com.datou.datouspringmvc.annotation.RequestMapping;
import com.datou.datouspringmvc.annotation.RequestParam;
import com.datou.datouspringmvc.annotation.Service;
import com.datou.entity.Monster;
import com.datou.service.MonsterService;

import java.lang.annotation.Documented;
import java.util.ArrayList;
import java.util.List;

@Service
public class MonsterServiceImpl implements MonsterService {
    @Override
    public List<Monster> listMonsters() {
        List<Monster> monsters = new ArrayList<>();
        monsters.add(new Monster(1, "monster1", "kill1", 1));
        monsters.add(new Monster(2, "monster2", "kill2", 2));
        return monsters;
    }


    public List<Monster> findMonsterByName(String name) {
        List<Monster> monsters = new ArrayList<>();
        monsters.add(new Monster(1, "monster1", "kill1", 1));
        monsters.add(new Monster(2, "monster2", "kill2", 2));
        monsters.add(new Monster(3, "monster3", "kill3", 3));
        monsters.add(new Monster(4, "monster4", "kill4", 4));

        List<Monster> result = new ArrayList<>();

        for(Monster monster : monsters) {
            if(monster.getName().contains(name)) {
                result.add(monster);
            }
        }
        return result;
    }

    @Override
    public boolean login(String name) {
        if ("monster1".equals(name)) {
            return true;
        }
        return false;
    }

}
